package com.polaris.live.dialog

import android.content.Context
import com.blankj.utilcode.util.StringUtils
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.common.ext.autoDp
import com.polaris.live.databinding.DialogVipEmojiBinding
import com.polaris.live.translation.R.string

/**
 * VipEmojiDialog 点击vip表情提示
 *
 * @author Created by 天晴 on 2024/12/16/025 11:35
 */
class VipEmojiDialog(
    context: Context,
    private val level: Int,
    private val ok: () -> Unit,
) : CenterPopupView(context) {

    private lateinit var mBinding: DialogVipEmojiBinding

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_vip_emoji
    }

    override fun onCreate() {
        super.onCreate()
        mBinding = DialogVipEmojiBinding.bind(popupImplView)
        mBinding.tipsTv.text = StringUtils.getString(string.only_vips_can_use_these_emojis, level)
        mBinding.cancelTv.setOnClickListener {
            dismiss()
        }
        mBinding.okTv.setOnClickListener {
            dismiss()
            ok.invoke()
        }
    }

    override fun getMaxWidth(): Int {
        return 295.autoDp
    }

    override fun getPopupWidth(): Int {
        return 295.autoDp
    }

    companion object {

        fun show(
            context: Context,
            level: Int,
            ok: () -> Unit,
        ) {

            XPopup.Builder(context)
                .isViewMode(false)
                .hasShadowBg(true)
                .hasNavigationBar(false)
                .moveUpToKeyboard(false)
                .navigationBarColor(R.color.color_transparent)
                .isDestroyOnDismiss(true)
                .asCustom(VipEmojiDialog(context, level, ok))
                .show()
        }
    }
}